package in.muton.panels.paginator.components.badges;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.components.images.ProfileImage;
import in.muton.edushare.pages.coursepages.CourseDept;
import in.muton.edushare.pages.coursepages.CoursePage;
import in.muton.edushare.pages.coursepages.CoursePeople;
import in.muton.edushare.pages.coursepages.CourseUniv;
import in.muton.edushare.pages.publicpages.coursepages.CoursePublic;
import in.muton.edushare.processing.objects.CourseDataHandler;
import in.muton.edushare.url.EntityPageParams;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.vo.Courses;
import com.edushare.common.vo.Users;

public class CourseBadgeWide extends Panel {

	public CourseBadgeWide(String id, IModel<Courses> model) {
		super(id, model);
		Users u = EduShareSession.get().getLoggedInUser();
		add(CSSPackageResource.getHeaderContribution(CourseBadge.class,
				"badge.css"));
		PageParameters p = EntityPageParams.getParams(model);
		add(new ProfileImage("images", model,
				ApplicationConstants.FILE_SUFFIX_THUMB));
		Link<Void> l;
		if(u != null){
			add(l = new BookmarkablePageLink<Void>("courseLink", CoursePage.class,p));
		}
		else{
			PageParameters params2 = new PageParameters();
			params2.put("0", model.getObject().getCourseName());
			params2.put("1", model.getObject().getCourseId().toString());
			add(l = new BookmarkablePageLink<Void>("courseLink", CoursePublic.class,params2));
		}
		l.add(new Label("name", model.getObject().getCourseName()));
		add(new Label("desc", model.getObject().getCourseDesc()).setEscapeModelStrings(false));
		
		if(u == null){
			add(new WebMarkupContainer("univ").setVisible(false));
			add(new WebMarkupContainer("dept").setVisible(false));
			add(new WebMarkupContainer("people").setVisible(false));
		}else{
			add(new BookmarkablePageLink<Void>("univ", CourseUniv.class, p));
			add(new BookmarkablePageLink<Void>("dept", CourseDept.class, p));
			add(new BookmarkablePageLink<Void>("people", CoursePeople.class, p));
		}
	}

	CourseDataHandler cdh = null;
	private static final long serialVersionUID = -8643277130716023634L;
}
